package com.genesis.yunnanji.activity;

import android.content.Intent;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.genesis.yunnanji.R;
import com.genesis.yunnanji.adapter.DiZhouDeliciousFoodAdapter;
import com.genesis.yunnanji.adapter.DiZhouHotelAdapter;
import com.genesis.yunnanji.adapter.DiZhouRoomPriceAdapter;
import com.genesis.yunnanji.adapter.DiZhouSpecialtyAdapter;
import com.genesis.yunnanji.adapter.DiZhouTripAdapter;
import com.genesis.yunnanji.adapter.DiZhouJingDianAdapter;
import com.genesis.yunnanji.bean.DiZhouDeliciousFoodBean;
import com.genesis.yunnanji.bean.DiZhouHotelBean;
import com.genesis.yunnanji.bean.DiZhouRoomPriceBean;
import com.genesis.yunnanji.bean.DiZhouSpecialtyBean;
import com.genesis.yunnanji.bean.DiZhouTripBean;
import com.genesis.yunnanji.bean.DiZhouJingDianBean;
import com.genesis.yunnanji.config.GenesisApiConfig;
import com.genesis.yunnanji.utils.NetWorkUtils;
import com.google.gson.Gson;
import com.jaeger.library.StatusBarUtil;
import com.lcodecore.tkrefreshlayout.RefreshListenerAdapter;
import com.lcodecore.tkrefreshlayout.TwinklingRefreshLayout;
import com.yqritc.recyclerviewflexibledivider.HorizontalDividerItemDecoration;

import org.json.JSONObject;
import org.xutils.http.RequestParams;
import org.xutils.view.annotation.ViewInject;

import java.util.ArrayList;
import java.util.List;

/**
 * 创建日期：2018/11/1 0001
 * 作者：Kite
 * 描述：单独列表界面
 */
public class SingleRecyclerActivity extends BaseActivity {

    @ViewInject(R.id.toolbar)
    Toolbar toolbar;

    @ViewInject(R.id.toolbarTitle)
    TextView toolbarTitle;

    @ViewInject(R.id.rv_content)
    RecyclerView rvContent;

    @ViewInject(R.id.llParentLayout)
    LinearLayout llParentLayout;

    @ViewInject(R.id.noDateLayout)
    RelativeLayout noDateLayout;

    @ViewInject(R.id.bga_newshome_refresh)
    TwinklingRefreshLayout refreshLayout;

    private DiZhouTripAdapter mDiZhouTripAdapter;//出行
    private List<DiZhouTripBean.ResultBean.ListBean> mTripList = new ArrayList<>();//出行
    private List<DiZhouTripBean.ResultBean.ListBean> mLocationTripList = new ArrayList<>();//出行

    private DiZhouHotelAdapter mHotelAdapter;//民宿
    private List<DiZhouHotelBean.ResultBean.ListBean> mHotelList = new ArrayList<>();//民宿
    private List<DiZhouHotelBean.ResultBean.ListBean> mLocationHotelList = new ArrayList<>();//民宿

    private DiZhouRoomPriceAdapter mDiZhouRoomPriceAdapter;//房价
    private List<DiZhouRoomPriceBean.ResultBean.ListBean> mRoomPriceList = new ArrayList<>();//民宿
    private List<DiZhouRoomPriceBean.ResultBean.ListBean> mLocationRoomPriceList = new ArrayList<>();//民宿

    private DiZhouJingDianAdapter mDiZhouJingDianAdapter;//景点
    private List<DiZhouJingDianBean.ResultBean.ListBean> mJingDianList = new ArrayList<>();//景点
    private List<DiZhouJingDianBean.ResultBean.ListBean> mLocationJingDianList = new ArrayList<>();

    private DiZhouSpecialtyAdapter mDiZhouSpecialtyAdapter;//特产非遗菌库(类别ID：1，特产，2菌库，15，非遗)
    private List<DiZhouSpecialtyBean.ResultBean.ListBean> mSpecialtyList = new ArrayList<>();//景点特产非遗菌库
    private List<DiZhouSpecialtyBean.ResultBean.ListBean> mLocationSpecialtyList = new ArrayList<>();//景点特产非遗菌库

    private DiZhouDeliciousFoodAdapter mDiZhouDeliciousFoodAdapter;//美食
    private List<DiZhouDeliciousFoodBean.ResultBean.ListBean> mDeliciousFoodList = new ArrayList<>();//美食
    private List<DiZhouDeliciousFoodBean.ResultBean.ListBean> mLocationDeliciousFoodList = new ArrayList<>();//美食


    private int mPage = 1;//页码

    private String mActivityKind;//传递过来的参数

    private String mIDKind;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState, R.layout.activity_single_recycler);
    }

    @Override
    protected void initView(Bundle savedInstanceState) {
        StatusBarUtil.setColor(this, getResources().getColor(R.color.main_color), 2);
        toolbar.setNavigationIcon(R.mipmap.return_white);
        toolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        initView();
    }

    @Override
    protected void setUpView() {
        Intent intent = getIntent();
        mIDKind = intent.getStringExtra("id");
        mActivityKind = intent.getStringExtra("thing");
        switch (mActivityKind) {
            case "trip":
                toolbarTitle.setText("大理出行");
                initTrip(mIDKind, refreshLayout);
                break;
            case "mingsu":
                toolbarTitle.setText("酒店民宿");
                initHotel(mIDKind, refreshLayout);
                break;
            case "fangjia":
                toolbarTitle.setText("当地房价");
                initRoomPrice(mIDKind, refreshLayout);
                break;
            case "wenlv":
                toolbarTitle.setText("文旅地产");
                break;
            case "jingdian":
                toolbarTitle.setText("旅游景点");
                initJingDian(mIDKind, refreshLayout);
                break;
            case "feiyi":
                toolbarTitle.setText("非遗文化");
                initSpecialty(mIDKind, "15", refreshLayout);
                break;
            case "yeshengjun":
                toolbarTitle.setText("野生菌");
                initSpecialty(mIDKind, "2", refreshLayout);
                break;
            case "meishi":
                toolbarTitle.setText("特色美食");
                initDeliciousFood(mIDKind, refreshLayout);
                break;
            case "techan":
                toolbarTitle.setText("本地特产");
                initSpecialty(mIDKind, "1", refreshLayout);
                break;
        }
    }

    private void initTrip(String id, final TwinklingRefreshLayout refreshLayout) {
        RequestParams params = new RequestParams(GenesisApiConfig.HOST + GenesisApiConfig.DIZHOU_ZUCHE);
        params.addBodyParameter("dizhouid", id);
        params.addBodyParameter("p", mPage + "");
        params.addBodyParameter("row", "10");
        NetWorkUtils.doCacheGet(params, new NetWorkUtils.HttpResultListener() {
            @Override
            public void onSuccess(JSONObject jsonObject) {
                refreshLayout.finishRefreshing();
                refreshLayout.finishLoadmore();
                Gson gson = new Gson();
                DiZhouTripBean bean = gson.fromJson(jsonObject.toString(), DiZhouTripBean.class);
                if (bean.getStatus() == 200) {
                    mTripList = bean.getResult().getList();
                    for (int i = 0; i < mTripList.size(); i++) {
                        mLocationTripList.add(new DiZhouTripBean.ResultBean.ListBean(mTripList.get(i).getId(), mTripList.get(i).getTitle(),
                                mTripList.get(i).getCover_img(), mTripList.get(i).getShop_time(), mTripList.get(i).getPhone(), mTripList.get(i).getAddr(),
                                mTripList.get(i).getDescription()));
                    }
                    if (mPage == 1) {
                        mDiZhouTripAdapter = new DiZhouTripAdapter(SingleRecyclerActivity.this, mLocationTripList);
                        rvContent.setAdapter(mDiZhouTripAdapter);
                        mDiZhouTripAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
                            @Override
                            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
                            }
                        });
                    } else {
                        mDiZhouTripAdapter.notifyDataSetChanged();
                    }
                } else if (bean.getStatus() == 102) {
                    if (mLocationTripList.size() == 0) {
                        noDateLayout.setVisibility(View.VISIBLE);
                        refreshLayout.setVisibility(View.GONE);
                    } else {
                        noDateLayout.setVisibility(View.GONE);
                        refreshLayout.setVisibility(View.VISIBLE);
                    }
                } else {
                    Toast.makeText(SingleRecyclerActivity.this, bean.getMessage(), Toast.LENGTH_SHORT).show();
                }
            }

            @Override
            public void OnCached(JSONObject jsonObject) {
            }

            @Override
            public void onFinished() {
                refreshLayout.finishRefreshing();
                refreshLayout.finishLoadmore();
            }

            @Override
            public void onError(String errorStr) {
                refreshLayout.finishRefreshing();
                refreshLayout.finishLoadmore();
            }
        });
    }

    private void initHotel(String id, final TwinklingRefreshLayout refreshLayout) {
        RequestParams params = new RequestParams(GenesisApiConfig.HOST + GenesisApiConfig.DIZHOU_HOTEL);
        params.addBodyParameter("dizhouid", id);
        params.addBodyParameter("p", mPage + "");
        params.addBodyParameter("row", "10");
        NetWorkUtils.doCacheGet(params, new NetWorkUtils.HttpResultListener() {
            @Override
            public void onSuccess(JSONObject jsonObject) {
                refreshLayout.finishRefreshing();
                refreshLayout.finishLoadmore();
                Gson gson = new Gson();
                DiZhouHotelBean bean = gson.fromJson(jsonObject.toString(), DiZhouHotelBean.class);
                if (bean.getStatus() == 200) {
                    mHotelList = bean.getResult().getList();
                    for (int i = 0; i < mHotelList.size(); i++) {
                        mLocationHotelList.add(new DiZhouHotelBean.ResultBean.ListBean(mHotelList.get(i).getId(), mHotelList.get(i).getTitle(),
                                mHotelList.get(i).getType(), mHotelList.get(i).getCover_img(), mHotelList.get(i).getOpendate(),
                                mHotelList.get(i).getPhone(), mHotelList.get(i).getAddr(), mHotelList.get(i).getDescription()));
                    }
                    if (mPage == 1) {
                        mHotelAdapter = new DiZhouHotelAdapter(SingleRecyclerActivity.this, mLocationHotelList);
                        rvContent.setAdapter(mHotelAdapter);
                        mHotelAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
                            @Override
                            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
                            }
                        });
                    } else {
                        mHotelAdapter.notifyDataSetChanged();
                    }
                } else if (bean.getStatus() == 102) {
                    if (mLocationHotelList.size() == 0) {
                        noDateLayout.setVisibility(View.VISIBLE);
                        refreshLayout.setVisibility(View.GONE);
                    } else {
                        noDateLayout.setVisibility(View.GONE);
                        refreshLayout.setVisibility(View.VISIBLE);
                    }
                } else {
                    Toast.makeText(SingleRecyclerActivity.this, bean.getMessage(), Toast.LENGTH_SHORT).show();
                }
            }

            @Override
            public void OnCached(JSONObject jsonObject) {
            }

            @Override
            public void onFinished() {
                refreshLayout.finishRefreshing();
                refreshLayout.finishLoadmore();
            }

            @Override
            public void onError(String errorStr) {
                refreshLayout.finishRefreshing();
                refreshLayout.finishLoadmore();
            }
        });
    }

    private void initRoomPrice(String id, final TwinklingRefreshLayout refreshLayout) {
        RequestParams params = new RequestParams(GenesisApiConfig.HOST + GenesisApiConfig.DIZHOU_FANG);
        params.addBodyParameter("dizhouid", id);
        params.addBodyParameter("p", mPage + "");
        params.addBodyParameter("row", "10");
        NetWorkUtils.doCacheGet(params, new NetWorkUtils.HttpResultListener() {
            @Override
            public void onSuccess(JSONObject jsonObject) {
                refreshLayout.finishRefreshing();
                refreshLayout.finishLoadmore();
                Gson gson = new Gson();
                DiZhouRoomPriceBean bean = gson.fromJson(jsonObject.toString(), DiZhouRoomPriceBean.class);
                if (bean.getStatus() == 200) {
                    mRoomPriceList = bean.getResult().getList();
                    for (int i = 0; i < mRoomPriceList.size(); i++) {
                        mLocationRoomPriceList.add(new DiZhouRoomPriceBean.ResultBean.ListBean(mRoomPriceList.get(i).getId(),
                                mRoomPriceList.get(i).getTitle(), mRoomPriceList.get(i).getCompany(), mRoomPriceList.get(i).getCover_img(),
                                mRoomPriceList.get(i).getPrice(), mRoomPriceList.get(i).getPhone(), mRoomPriceList.get(i).getAddr(),
                                mRoomPriceList.get(i).getDescription()));
                    }
                    if (mPage == 1) {
                        mDiZhouRoomPriceAdapter = new DiZhouRoomPriceAdapter(SingleRecyclerActivity.this, mLocationRoomPriceList);
                        rvContent.setAdapter(mDiZhouRoomPriceAdapter);
                        mDiZhouRoomPriceAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
                            @Override
                            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
                            }
                        });
                    } else {
                        mDiZhouRoomPriceAdapter.notifyDataSetChanged();
                    }
                } else if (bean.getStatus() == 102) {
                    if (mLocationRoomPriceList.size() == 0) {
                        noDateLayout.setVisibility(View.VISIBLE);
                        refreshLayout.setVisibility(View.GONE);
                    } else {
                        noDateLayout.setVisibility(View.GONE);
                        refreshLayout.setVisibility(View.VISIBLE);
                    }
                } else {
                    Toast.makeText(SingleRecyclerActivity.this, bean.getMessage(), Toast.LENGTH_SHORT).show();
                }
            }

            @Override
            public void OnCached(JSONObject jsonObject) {
            }

            @Override
            public void onFinished() {
                refreshLayout.finishRefreshing();
                refreshLayout.finishLoadmore();
            }

            @Override
            public void onError(String errorStr) {
                refreshLayout.finishRefreshing();
                refreshLayout.finishLoadmore();
            }
        });
    }

    private void initJingDian(final String id, final TwinklingRefreshLayout refreshLayout) {
        RequestParams params = new RequestParams(GenesisApiConfig.HOST + GenesisApiConfig.DIZHOU_JINGDAIN);
        params.addBodyParameter("dizhouid", id);
        params.addBodyParameter("p", mPage + "");
        params.addBodyParameter("row", "10");
        NetWorkUtils.doCacheGet(params, new NetWorkUtils.HttpResultListener() {
            @Override
            public void onSuccess(JSONObject jsonObject) {
                refreshLayout.finishRefreshing();
                refreshLayout.finishLoadmore();
                Gson gson = new Gson();
                DiZhouJingDianBean bean = gson.fromJson(jsonObject.toString(), DiZhouJingDianBean.class);
                if (bean.getStatus() == 200) {
                    mJingDianList = bean.getResult().getList();
                    for (int i = 0; i < mJingDianList.size(); i++) {
                        mLocationJingDianList.add(new DiZhouJingDianBean.ResultBean.ListBean(mJingDianList.get(i).getId()
                                , mJingDianList.get(i).getTitle(), mJingDianList.get(i).getCover_img(), mJingDianList.get(i).getOpendate()
                                , mJingDianList.get(i).getTicket_price(), mJingDianList.get(i).getAddr()));
                    }
                    if (mPage == 1) {
                        mDiZhouJingDianAdapter = new DiZhouJingDianAdapter(SingleRecyclerActivity.this, mLocationJingDianList);
                        rvContent.setAdapter(mDiZhouJingDianAdapter);
                        mDiZhouJingDianAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
                            @Override
                            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
                                Intent intent = new Intent(SingleRecyclerActivity.this, DiZhouJingDianDetailsActivity.class);
                                intent.putExtra("id", mLocationJingDianList.get(position).getId());
                                startActivity(intent);
                            }
                        });
                    } else {
                        mDiZhouJingDianAdapter.notifyDataSetChanged();
                    }
                } else if (bean.getStatus() == 102) {
                    if (mLocationJingDianList.size() == 0) {
                        noDateLayout.setVisibility(View.VISIBLE);
                        refreshLayout.setVisibility(View.GONE);
                    } else {
                        noDateLayout.setVisibility(View.GONE);
                        refreshLayout.setVisibility(View.VISIBLE);
                    }
                } else {
                    Toast.makeText(SingleRecyclerActivity.this, bean.getMessage(), Toast.LENGTH_SHORT).show();
                }
            }

            @Override
            public void OnCached(JSONObject jsonObject) {
            }

            @Override
            public void onFinished() {
                refreshLayout.finishRefreshing();
                refreshLayout.finishLoadmore();
            }

            @Override
            public void onError(String errorStr) {
                refreshLayout.finishRefreshing();
                refreshLayout.finishLoadmore();
            }
        });
    }

    private void initSpecialty(String id, final String type, final TwinklingRefreshLayout refreshLayout) {
        RequestParams params = new RequestParams(GenesisApiConfig.HOST + GenesisApiConfig.DIZHOU_SPECIALTY);
        params.addBodyParameter("dizhouid", id);
        params.addBodyParameter("categoryid", type);
        params.addBodyParameter("p", mPage + "");
        params.addBodyParameter("row", "10");
        NetWorkUtils.doCacheGet(params, new NetWorkUtils.HttpResultListener() {
            @Override
            public void onSuccess(JSONObject jsonObject) {
                refreshLayout.finishRefreshing();
                refreshLayout.finishLoadmore();
                Gson gson = new Gson();
                DiZhouSpecialtyBean bean = gson.fromJson(jsonObject.toString(), DiZhouSpecialtyBean.class);
                if (bean.getStatus() == 200) {
                    mSpecialtyList = bean.getResult().getList();
                    for (int i = 0; i < mSpecialtyList.size(); i++) {
                        mLocationSpecialtyList.add(new DiZhouSpecialtyBean.ResultBean.ListBean(mSpecialtyList.get(i).getId(),
                                mSpecialtyList.get(i).getCategory_id(), mSpecialtyList.get(i).getTitle(), mSpecialtyList.get(i).getCover_img(),
                                mSpecialtyList.get(i).getDescription()));
                    }
                    if (mPage == 1) {
                        mDiZhouSpecialtyAdapter = new DiZhouSpecialtyAdapter(SingleRecyclerActivity.this, mLocationSpecialtyList);
                        rvContent.setAdapter(mDiZhouSpecialtyAdapter);
                        mDiZhouSpecialtyAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
                            @Override
                            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
                                Intent intent = new Intent(SingleRecyclerActivity.this, GoodsDetailsActivity.class);
                                intent.putExtra("id", mSpecialtyList.get(position).getId());
                                intent.putExtra("case", type);
                                intent.putExtra("title", mSpecialtyList.get(position).getTitle());
                                intent.putExtra("img", mSpecialtyList.get(position).getCover_img());
                                startActivity(intent);
                            }
                        });
                    } else {
                        mDiZhouSpecialtyAdapter.notifyDataSetChanged();
                    }
                } else if (bean.getStatus() == 102) {
                    if (mLocationSpecialtyList.size() == 0) {
                        noDateLayout.setVisibility(View.VISIBLE);
                        refreshLayout.setVisibility(View.GONE);
                    } else {
                        noDateLayout.setVisibility(View.GONE);
                        refreshLayout.setVisibility(View.VISIBLE);
                    }
                } else {
                    Toast.makeText(SingleRecyclerActivity.this, bean.getMessage(), Toast.LENGTH_SHORT).show();
                }
            }

            @Override
            public void OnCached(JSONObject jsonObject) {
            }

            @Override
            public void onFinished() {
                refreshLayout.finishRefreshing();
                refreshLayout.finishLoadmore();
            }

            @Override
            public void onError(String errorStr) {
                refreshLayout.finishRefreshing();
                refreshLayout.finishLoadmore();
            }
        });
    }

    private void initDeliciousFood(String id, final TwinklingRefreshLayout refreshLayout) {
        DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(context, DividerItemDecoration.VERTICAL);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
            dividerItemDecoration.setDrawable(ContextCompat.getDrawable(context, R.drawable.divider_horizontal_10dp));
        rvContent.addItemDecoration(dividerItemDecoration);
        RequestParams params = new RequestParams(GenesisApiConfig.HOST + GenesisApiConfig.DIZHOU_MEISHI);
        params.addBodyParameter("dizhouid", id);
        params.addBodyParameter("p", mPage + "");
        params.addBodyParameter("row", "10");
        NetWorkUtils.doCacheGet(params, new NetWorkUtils.HttpResultListener() {
            @Override
            public void onSuccess(JSONObject jsonObject) {
                refreshLayout.finishRefreshing();
                refreshLayout.finishLoadmore();
                Gson gson = new Gson();
                DiZhouDeliciousFoodBean bean = gson.fromJson(jsonObject.toString(), DiZhouDeliciousFoodBean.class);
                if (bean.getStatus() == 200) {
                    mDeliciousFoodList = bean.getResult().getList();
                    for (int i = 0; i < mDeliciousFoodList.size(); i++) {
                        mLocationDeliciousFoodList.add(new DiZhouDeliciousFoodBean.ResultBean.ListBean(mDeliciousFoodList.get(i).getId(),
                                mDeliciousFoodList.get(i).getTitle(), mDeliciousFoodList.get(i).getCover_img(), mDeliciousFoodList.get(i).getDescription()));
                    }
                    if (mPage == 1) {
                        mDiZhouDeliciousFoodAdapter = new DiZhouDeliciousFoodAdapter(SingleRecyclerActivity.this, mLocationDeliciousFoodList);
                        rvContent.setAdapter(mDiZhouDeliciousFoodAdapter);
                        mDiZhouDeliciousFoodAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
                            @Override
                            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
//                            Intent intent = new Intent(SingleRecyclerActivity.this, GoodsDetailsActivity.class);
//                            intent.putExtra("id", mDeliciousFoodList.get(position).getId());
//                            intent.putExtra("case", "1");
//                            intent.putExtra("title", mDeliciousFoodList.get(position).getTitle());
//                            intent.putExtra("img", mDeliciousFoodList.get(position).getCover_img());
//                            startActivity(intent);
                            }
                        });
                    } else {
                        mDiZhouDeliciousFoodAdapter.notifyDataSetChanged();
                    }
                } else if (bean.getStatus() == 102) {
                    if (mLocationDeliciousFoodList.size() == 0) {
                        noDateLayout.setVisibility(View.VISIBLE);
                        refreshLayout.setVisibility(View.GONE);
                    } else {
                        noDateLayout.setVisibility(View.GONE);
                        refreshLayout.setVisibility(View.VISIBLE);
                    }
                } else {
                    Toast.makeText(SingleRecyclerActivity.this, bean.getMessage(), Toast.LENGTH_SHORT).show();
                }
            }

            @Override
            public void OnCached(JSONObject jsonObject) {
            }

            @Override
            public void onFinished() {
                refreshLayout.finishRefreshing();
                refreshLayout.finishLoadmore();
            }

            @Override
            public void onError(String errorStr) {
                refreshLayout.finishRefreshing();
                refreshLayout.finishLoadmore();
            }
        });
    }

    private void initView() {
        rvContent.setLayoutManager(new LinearLayoutManager(SingleRecyclerActivity.this));
        rvContent.addItemDecoration(new HorizontalDividerItemDecoration.Builder(SingleRecyclerActivity.this).color(getResources().getColor(R.color.divider)).build());
        refreshLayout.setOnRefreshListener(new RefreshListenerAdapter() {
            @Override
            public void onRefresh(TwinklingRefreshLayout refreshLayout) {
                super.onRefresh(refreshLayout);
                mPage = 1;
                switch (mActivityKind) {
                    case "trip":
                        mLocationTripList.clear();
                        initTrip(mIDKind, refreshLayout);
                        break;
                    case "mingsu":
                        mLocationHotelList.clear();
                        initHotel(mIDKind, refreshLayout);
                        break;
                    case "fangjia":
                        mLocationRoomPriceList.clear();
                        initRoomPrice(mIDKind, refreshLayout);
                        break;
                    case "wenlv":
                        break;
                    case "jingdian":
                        mLocationJingDianList.clear();
                        initJingDian(mIDKind, refreshLayout);
                        break;
                    case "feiyi":
                        mLocationSpecialtyList.clear();
                        initSpecialty(mIDKind, "15", refreshLayout);
                        break;
                    case "yeshengjun":
                        mLocationSpecialtyList.clear();
                        initSpecialty(mIDKind, "2", refreshLayout);
                        break;
                    case "meishi":
                        mLocationDeliciousFoodList.clear();
                        initDeliciousFood(mIDKind, refreshLayout);
                        break;
                    case "techan":
                        mLocationSpecialtyList.clear();
                        initSpecialty(mIDKind, "1", refreshLayout);
                        break;
                }
            }

            @Override
            public void onLoadMore(TwinklingRefreshLayout refreshLayout) {
                super.onLoadMore(refreshLayout);
                mPage += 1;
                switch (mActivityKind) {
                    case "trip":
                        initTrip(mIDKind, refreshLayout);
                        break;
                    case "mingsu":
                        initHotel(mIDKind, refreshLayout);
                        break;
                    case "fangjia":
                        initRoomPrice(mIDKind, refreshLayout);
                        break;
                    case "wenlv":
                        break;
                    case "jingdian":
                        initJingDian(mIDKind, refreshLayout);
                        break;
                    case "feiyi":
                        initSpecialty(mIDKind, "15", refreshLayout);
                        break;
                    case "yeshengjun":
                        initSpecialty(mIDKind, "2", refreshLayout);
                        break;
                    case "meishi":
                        initDeliciousFood(mIDKind, refreshLayout);
                        break;
                    case "techan":
                        initSpecialty(mIDKind, "1", refreshLayout);
                        break;
                }
            }
        });
    }

}
